<?php

namespace App\Models\WorkOrder;

use App\Models\BaseModel;
use App\Models\Traits\KfUid;

class WorkOrderOperateLogModel extends BaseModel
{
    use KfUid;

    protected $table = 'work_order_operate_log';

    const TYPE_1  = 1;
    const TYPE_2  = 2;
    const TYPE_3  = 3;
    const TYPE_4  = 4;
    const TYPE_5  = 5;
    const TYPE_6  = 6;
    const TYPE_7  = 7;
    const TYPE_8  = 8;
    const TYPE_9  = 9;
    const TYPE_10 = 10;
    const TYPE_11 = 11;
    const TYPE_12 = 12;
    const TYPE_13 = 13;
    const TYPE_14 = 14;
    const TYPE_15 = 15;
    const TYPE_16 = 16;
    const TYPE_17 = 17;

    const TYPE_TEXT = [
        self::TYPE_1  => "提交工单",
        self::TYPE_2  => "客服抢单",
        self::TYPE_3  => "客服初审 (提交解决方案)",
        self::TYPE_4  => "客服初审 (提交备注)",
        self::TYPE_5  => "业务处理-1 (提交解决方案)",
        self::TYPE_6  => "业务处理-1 (提交备注)",
        self::TYPE_7  => "业务处理-2 (提交解决方案)",
        self::TYPE_8  => "业务处理-2 (提交备注)",
        self::TYPE_9  => "重新提交工单",
        self::TYPE_10 => "标记完成工单",
        self::TYPE_11 => "关闭工单",
        self::TYPE_12 => "驳回工单",
        self::TYPE_13 => "提交工单(驳回后再次提交)",
        self::TYPE_14 => "商家确认完成",
        self::TYPE_15 => "工单转交",
        self::TYPE_16 => '功能开通重置(关闭工单)',
        self::TYPE_17 => '自动通过',
    ];

    /**
     * @param string $workOrderNo
     * @param int $step
     * @param int $type
     * @param string $username
     * @param int $uid
     * @param string $content
     */
    public static function generateOperateLog(
        string $workOrderNo,
        int $step,
        int $type,
        string $username,
        int $uid,
        string $content = ""
    ) {
        self::query()->insert([
            "workOrderNo"     => $workOrderNo,
            "step"            => $step,
            "type"            => $type,
            "content"         => $content,
            "createdByUid"    => $uid,
            "createdUsername" => $username,
            "createdAt"       => time()
        ]);
    }

}
